home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / MEMORY.SWG / 0056_PROTECTED MODE.pas < prev    next >
Pascal/Delphi Source File  |  1994-08-24  |  3KB  |  121 lines

  1.  
  2. {
  3.  SM> I have a bit of a problem with pascal 7 protected mode,
  4.  SM> I have a TSR (assembly) that does my comms work for me.
  5.  SM> I use intr(regs) with various settings to the registers to collect
  6.  SM> data from the TSR. However when in protected mode my TSR seems
  7.  SM> to be unavailable.
  8.  
  9. I had the same problem, it seems that the DOS unit does not support protected
  10. mode interrupt handling. I solved it by looking though some documentation I
  11. found on protected mode, below is a simple unit to set and get protected
  12. mode interrupts.
  13.  
  14. In my case the interrupt goes about 22Khz so it kept switching into real mode
  15. and back just to handle the interrupt, the result it crashed.
  16.  
  17.  SM> Do I need to switch to real mode from the app.
  18.  SM> (if so how, I can't find it in the manual).
  19.  
  20. No, see above.
  21.  
  22.  SM> Do I need to modify my TSR.
  23.  SM> I presume not because I'm sure that the mouse drivers can be got
  24.  SM> to work.
  25.  
  26. The MOUSE is handled by the DOS extender.
  27.  
  28. Cheers
  29.   Rob
  30.  
  31. P.S. I noticed that you use the same BBS, if you have any problems drop
  32. me a note.
  33. }
  34.  
  35. Unit DPMIDos;  { This code was a quick hack job to solve my problem }
  36.                { don't expect it to be neat!                        }
  37.  
  38. INTERFACE
  39.  
  40. Function RealMode : Boolean;
  41. Function AllocateLDT(NumberDescriptors : Word) : Word;
  42. Function FreeLDT(Selector : Word) : Boolean;
  43. Function SegmentToDescriptor(Segment : Word) : Word;
  44. Function GetNextSelectorInc : Word;
  45. Function GetDPMIntVec(IntNumber : Byte) : Pointer;
  46. Procedure SetDPMIntVec(IntNumber : Byte; IntVec : Pointer);
  47.  
  48. IMPLEMENTATION
  49.  
  50. Function RealMode : Boolean; assembler;
  51. asm
  52.   mov     ax, 01686h
  53.   int     02Fh
  54. end;
  55.  
  56. Function AllocateLDT(NumberDescriptors : Word) : Word; assembler;
  57. asm
  58.    mov     ax, 0000h
  59.    mov     ax, NumberDescriptors
  60.    int     031h
  61.    jnc     @Ok
  62.    mov     ax, 0
  63.  @Ok:
  64. end;
  65.  
  66. Function FreeLDT(Selector : Word) : Boolean; assembler;
  67. asm
  68.    mov     ax, 0001h
  69.    mov     bx, Selector
  70.    int     031h
  71.    mov     ax, 1
  72.    jnc     @Ok
  73.    mov     ax, 0
  74.  @Ok:
  75. end;
  76.  
  77. Function SegmentToDescriptor(Segment : Word) : Word; assembler;
  78. asm
  79.    mov     ax, 0002h
  80.    mov     bx, Segment
  81.    int     31h
  82.    jnc     @Ok
  83.    mov     ax, 0
  84.  @Ok:
  85. end;
  86.  
  87. Function GetNextSelectorInc : Word; assembler;
  88. asm
  89.    mov     ax, 0003h
  90.    int     031h
  91. end;
  92.  
  93.  
  94. Function GetDPMIntVec(IntNumber : Byte) : Pointer; {assembler;}
  95. Var S, O : Word;    { Too lazy to look in the manual! }
  96. Begin
  97.   asm
  98.      mov    ax, 0204h
  99.      mov    bl, IntNumber
  100.      int    031h
  101.      mov    S, cx
  102.      mov    O, dx
  103.   end;
  104.   GetDPMIntVec := Ptr(S, O);
  105. End;
  106.  
  107.  
  108. Procedure SetDPMIntVec(IntNumber : Byte; IntVec : Pointer); assembler;
  109. asm
  110.    mov    ax, 0205h
  111.    mov    bl, IntNumber
  112.  
  113.    les    dx, IntVec
  114.    mov    cx, es
  115.  
  116.    int    031h
  117. end;
  118.  
  119. begin
  120. end.
  121.